﻿using HeyPiPi_Desk.Base;
using MaterialDesignThemes.Wpf;
using Microsoft.Practices.Prism.Commands;
using Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace HeyPiPi_Desk.DomainViewModel
{
   public  class ChooseShopViewModel:BaseNotification
    {
        #region 字段/属性

        public delegate void ChooseShopIdDelegateHandler(shopinfo id);

        public event ChooseShopIdDelegateHandler ChooseShopIdEvent;

        private ObservableCollection<shopinfo> _shopinfos;

        /// <summary>
        /// 商铺列表
        /// </summary>
        public ObservableCollection<shopinfo> Shopinfos
        {
            get { return _shopinfos; }
            set { _shopinfos = value;this.RaisePropertyChanged(() => this.Shopinfos); }
        }

        /// <summary>
        /// 提交命令
        /// </summary>
        public DelegateCommand<object>  Submit_Cmd { get; set; }

        #endregion

        #region 共有方法
        public ChooseShopViewModel(List<shopinfo> shopinfos)
        {
            this.Shopinfos =new ObservableCollection<shopinfo>(Shopinfos);
            this.Submit_Cmd = new DelegateCommand<object>((obj) =>
            {
                if (obj is shopinfo shopinfo)
                {
                    this.ChooseShopIdEvent(shopinfo);
                    DialogHost.CloseDialogCommand.Execute(null, null);
                }
            });
        }
        #endregion

    }
}
